

package com.hazelcast.internal.usercodedeployment.impl.filter;

import com.hazelcast.internal.util.collection.ArrayUtils;
import com.hazelcast.internal.util.filter.Filter;

/**
 * All classes match unless they are in the explicit blacklist
 */
public class ClassBlacklistFilter implements Filter<String> {

    private final String[] blacklist;

    public ClassBlacklistFilter(String... blacklisted) {
        blacklist = ArrayUtils.createCopy(blacklisted);
    }

    @Override
    public boolean accept(String className) {
        for (String blacklisted : blacklist) {
            if (className.startsWith(blacklisted)) {
                return false;
            }
        }
        return true;
    }
}
